﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}


<div id="permissionListTable" class="main-content">
    <h3 class="page-title">权限管理(操作管理)(Authority management(Operation management)</h3>

    <div class="panel">
        <div class="panel-body">
            <button class="btn btn-primary" v-on:click="AddPermission">
                <i class="fa fa-user-plus"></i> 新增权限Add permission
            </button>
            <br />
            <br />
            <table class="table table-striped" v-if="isNotEmptyObject(permissionList)">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>权限名称Permission name</th>
                        <th>请求路径Request path</th>
                        <th>优先级priority</th>
                        <th>是否禁用whether Disable</th>
                        <th>父权限ID Parent permission ID</th>
                        <th>操作operation</th>
                    </tr>
                </thead>
                <tbody v-for="(permission, index) in permissionList">
                    <tr :id='"inputArea" + permission.BaseInfo.ID' class="info">
                        <td>
                            <div class="form-group">
                                <label class="form-control">{{permission.BaseInfo.ID}}</label>
                                <input type="hidden" class="form-control" v-model="permission.BaseInfo.ID" />
                            </div>
                        </td>
                        <td>
                            <div :id='"inputName" + permission.BaseInfo.ID' class="form-group">
                                <input type="text" class="form-control" v-model="permission.BaseInfo.Name" />
                            </div>
                        </td>
                        <td>
                            <div :id='"inputPageName" + permission.BaseInfo.ID' class="form-group">
                                <input type="text" class="form-control" v-model="permission.BaseInfo.UrlPath" />
                            </div>
                        </td>
                        <td>
                            <div :id='"inputPriority" + permission.BaseInfo.ID' class="form-group">
                                <input type="text" class="form-control" v-model="permission.BaseInfo.Priority" />
                            </div>
                        </td>
                        <td>
                            <div class="form-group">
                                <select class="form-control" v-model="permission.BaseInfo.IsDisable">
                                    <option v-for="(value, key, idx) in isDisableDictionary" v-bind:value="value">{{key}}</option>
                                </select>
                            </div>
                        </td>
                        <td>
                            <div class="form-group">
                                <label class="form-control">{{permission.BaseInfo.ParentID}}</label>
                                <input type="hidden" class="form-control" v-model="permission.BaseInfo.ParentID" />
                            </div>
                        </td>
                        <td>
                            <button :id='"btnSave" + permission.BaseInfo.ID' class="btn btn-success btn-sm" v-on:click="SavePermission(permission.BaseInfo)" v-if="permission.BaseInfo.ID == 0">
                                <i class="fa fa-save"></i> 保存preservation
                            </button>
                            <button :id='"btnCancelSave" + permission.BaseInfo.ID' class="btn btn-warning btn-sm" v-on:click="CancelSavePermission(permission.BaseInfo)" v-if="permission.BaseInfo.ID == 0">
                                <i class="fa fa-close"></i> 取消cancel
                            </button>
                            <button :id='"btnEdit" + permission.BaseInfo.ID' class="btn btn-info btn-sm" v-on:click="EditPermission(permission.BaseInfo)" v-if="permission.BaseInfo.ID > 0">
                                <i class="fa fa-edit"></i> 编辑edit
                            </button>
                            <button :id='"btnUpdate" + permission.BaseInfo.ID' class="btn btn-primary btn-sm" style="display: none;" v-on:click="UpdatePermission(permission.BaseInfo)">
                                <i class="fa fa-refresh"></i> 更新renew
                            </button>
                            <button :id='"btnCancelUpdate" + permission.BaseInfo.ID' class="btn btn-warning btn-sm" style="display: none;" v-on:click="CancelUpdatePermission(permission.BaseInfo)">
                                <i class="fa fa-close"></i> 取消cancel
                            </button>
                            <button :id='"btnDelete" + permission.BaseInfo.ID' class="btn btn-danger btn-sm" style="display: none;" v-on:click="DeletePermission(permission.BaseInfo)">
                                <i class="fa fa-trash-o"></i> 删除delete
                            </button>
                            <button :id='"btnAddSubRole" + permission.BaseInfo.ID' class="btn btn-success btn-sm" v-on:click="AddSubPermission(permission)" v-if="permission.BaseInfo.ID > 0 && !hasEditPermission">
                                <i class="fa fa-user-plus"></i> 新增子权限Add sub permission
                            </button>
                        </td>
                    </tr>
                    <tr :id='"inputArea" + subPermission.ID' v-for="(subPermission, subIndex) in permission.SubPermissions">
                        <td>
                            <div class="form-group">
                                <input type="hidden" class="form-control" v-model="subPermission.ID" />
                            </div>
                        </td>
                        <td>
                            <div :id='"inputName" + subPermission.ID' class="form-group">
                                <input type="text" class="form-control" v-model="subPermission.Name" />
                            </div>
                        </td>
                        <td>
                            <div :id='"inputPageName" + subPermission.ID' class="form-group">
                                <input type="text" class="form-control" v-model="subPermission.UrlPath" />
                            </div>
                        </td>
                        <td>
                            <div :id='"inputPriority" + subPermission.ID' class="form-group">
                                <input type="text" class="form-control" v-model="subPermission.Priority" />
                            </div>
                        </td>
                        <td>
                            <div class="form-group">
                                <select class="form-control" v-model="subPermission.IsDisable">
                                    <option v-for="(value, key, idx) in isDisableDictionary" v-bind:value="value">{{key}}</option>
                                </select>
                            </div>
                        </td>
                        <td>
                            <div class="form-group">
                                <label class="form-control">{{subPermission.ParentID}}</label>
                                <input type="hidden" class="form-control" v-model="subPermission.ParentID" />
                            </div>
                        </td>
                        <td>
                            <button :id='"btnSave" + subPermission.ID' class="btn btn-success btn-sm" v-on:click="SavePermission(subPermission)" v-if="subPermission.ID == 0">
                                <i class="fa fa-save"></i> 保存preservation
                            </button>
                            <button :id='"btnCancelSave" + subPermission.ID' class="btn btn-warning btn-sm" v-on:click="CancelSavePermission(subPermission)" v-if="subPermission.ID == 0">
                                <i class="fa fa-close"></i> 取消cancel
                            </button>
                            <button :id='"btnEdit" + subPermission.ID' class="btn btn-info btn-sm" v-on:click="EditPermission(subPermission)" v-if="subPermission.ID > 0">
                                <i class="fa fa-edit"></i> 编辑edit
                            </button>
                            <button :id='"btnUpdate" + subPermission.ID' class="btn btn-primary btn-sm" style="display: none;" v-on:click="UpdatePermission(subPermission)">
                                <i class="fa fa-refresh"></i> 更新renew
                            </button>
                            <button :id='"btnCancelUpdate" + subPermission.ID' class="btn btn-warning btn-sm" style="display: none;" v-on:click="CancelUpdatePermission(subPermission)">
                                <i class="fa fa-close"></i> 取消cancel
                            </button>
                            <button :id='"btnDelete" + subPermission.ID' class="btn btn-danger btn-sm" style="display: none;" v-on:click="DeletePermission(subPermission)">
                                <i class="fa fa-trash-o"></i> 删除delete
                            </button>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <!-- END TABLE -->
    <div class="alert alert-warning alert-dismissible" role="alert">
        <i class="fa fa-warning"></i>
        <p>目前权限的设计，不能控制页面上的空间显示或隐藏。The current permission design cannot control the display or hiding of space on the page</p>
        <p>用户权限的作用，是当用户操作页面数据时，服务器会判断通过，还是拒绝。The function of user permission is that when the user operates the page data, the server will judge whether to pass or reject</p>
        <p>如果权限的修改,会导致系统功能不能正常访问，如需修改则建议请联系开发人员协商。If the permission is modified, the system function cannot be accessed normally. If it needs to be modified, please contact the developer for negotiation</p>
    </div>
</div>


@section scripts{
    <script type="text/javascript" src="~/Scripts/pageJs/Account/Permission.js?v=@DateTime.Now.ToFileTimeUtc()"></script>
}
